package deepbitview

import grails.test.*
import org.junit.Test

class MtgoxServiceTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()

        assertFalse(MtGoxAccessHandler.isConfigured())

        MtGoxAccessHandler.register(System.getProperty("mtgox.username"), System.getProperty("mtgox.password"))

        assertTrue(MtGoxAccessHandler.isConfigured())

    }

    protected void tearDown() {
        super.tearDown()
    }

    @Test
    void testGetCurrentBalance() {

        MtgoxService mtgoxService = new MtgoxService()

        def result = mtgoxService.getCurrentBalance()

        assert (result)

        assert (result.usd > 0)
        assert (result.coins > 0)

    }


    @Test
    void testListOpenOrders() {

        MtgoxService mtgoxService = new MtgoxService()

        def value = mtgoxService.listOpenOrders()

        assert (value != false)
    }


    @Test
    void testPlaceBuyOrder() {

        MtgoxService mtgoxService = new MtgoxService()

        assert (mtgoxService.placeBuyOrder(0.01, 0.02) != null)

    }

}
